package com.xs.ahoi.hcxs.utils.tts;

import com.xs.ahoi.hcxs.utils.FileUtil;
import com.xs.ahoi.hcxs.utils.LogUtil;

import java.io.File;

import static com.xs.ahoi.hcxs.utils.Constants.*;

/**
 * author: cdfuhuichao
 * date: 2019/4/28 15:19
 * path: com.xs.ahoi.hcxs.utils.tts.OfflineResource
 * description: 检查离线bat文件是否存在，不存在就copy
 */
public class OfflineResource {

    public static void check() {
        String[] filenames = {BD_TTS_TEXT_FILENAME, BD_TTS_MODEL_FILENAME};
        for (String path : filenames) {
            String toPath = BD_TTS_DIR + "/" + path;
            File f = new File(toPath);
            if (!f.canRead()) {
                LogUtil.e("[ERROR] 文件不存在或者不可读取，正在复制assets目录同名文件到：" + toPath);
                FileUtil.copyFromAssets("tts/" + path, toPath);
            }
        }
    }


}
